package io.renren.modules.powercut.controller;

import java.util.Arrays;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.powercut.entity.RepeatDetailedEntity;
import io.renren.modules.powercut.service.RepeatDetailedService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 停电明细
 *
 * @author zhujinbo 1724282894@qq.com
 * @email 1724282894@qq.com
 * @date 2020-12-05 11:22:28
 */
@RestController
@RequestMapping("powercut/repeatdetailed")
@Api("停电明细")
public class RepeatDetailedController {
    @Autowired
    private RepeatDetailedService repeatDetailedService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @ApiOperation("列表")
    @RequiresPermissions("powercut:repeatdetailed:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = repeatDetailedService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 清空
     */
    @GetMapping("empty")
    @RequiresPermissions("powercut:repeatdetailed:empty")
    @ApiOperation("清空")
    public R empty(){
        QueryWrapper<RepeatDetailedEntity> repeatDetailedEntityQueryWrapper = new QueryWrapper<>();
        repeatDetailedService.remove(repeatDetailedEntityQueryWrapper);
        return R.ok();
    }

    /**
     * 导出
     */



    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("powercut:repeatdetailed:info")
    @ApiOperation("信息")
    public R info(@PathVariable("id") String id){
        RepeatDetailedEntity repeatDetailedEntity = repeatDetailedService.queryRepeatDetailedById(id);
        return R.ok().put("repeatDetailed",repeatDetailedEntity);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("powercut:repeatdetailed:save")
    public R save(@RequestBody RepeatDetailedEntity repeatDetailed){
		repeatDetailedService.save(repeatDetailed);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("powercut:repeatdetailed:update")
    public R update(@RequestBody RepeatDetailedEntity repeatDetailed){
		repeatDetailedService.updateById(repeatDetailed);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("powercut:repeatdetailed:delete")
    public R delete(@RequestBody String[] ids){
		repeatDetailedService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
